<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>MakeDown Online</title>
		<script src="marked.js" type="text/javascript" charset="utf-8"></script>
		
		<link rel="stylesheet" type="text/css" href="marked.css"/>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}
			html,body {
				width: 100%;
				height: 100%;
				font-size: 16px;
				overflow: hidden;
				
			}
			#tbox {
				width: 50%;
				height: 100%;
				border:0;
				box-sizing: border-box;
				float: left;
				padding: 20px;
				outline: 0;
				background:#F9F9F5;
			}
			#content {
				width: 50%;
				height: 100%;
				float: left;
				padding: 20px;
				box-sizing: border-box;
				background:#F9F9F5;
				overflow-y: auto;
    				overflow-x: hidden;
			}
		</style>
	</head>
	<body>
		<textarea id="tbox" rows="" cols=""></textarea>
		<div id="content"></div>
		  <script>
		  	var box = document.getElementById("tbox");
		  	box.value = localStorage.getItem('value');
		  	if (localStorage.getItem('content')) {
			  	markedValue(localStorage.getItem('content'));
		  	}
		  	marked.setOptions({
		  		renderer: new marked.Renderer(),
				  gfm: true,
				  tables: true,
				  breaks: true,
				  pedantic: false,
				  sanitize: true,
				  smartLists: true,
				  smartypants: false
		  	});
		  	
		  	box.oninput = function() {
		  		console.log(this.value);
		  		markedValue(this.value);
		  		localStorage.setItem('value',this.value);
		  		localStorage.setItem('content',document.getElementById('content').innerHTML);
		  	}
		  	function markedValue(value) {
		  		document.getElementById('content').innerHTML = marked(value);
		  	}
		  </script>
	</body>
</html>
